class AudioAsset < ActiveRecord::Base
  has_many :replicas
  
  EssenceFileType  = 'essence'
  MetadataFileType = 'metadata'
  
  def essence_file?
    find_main_essence ? true : false
  end
  
  def metadata_file?
    find_main_metadata ? true : false
  end
  
  def find_main_essence
    self.replicas.find :first, :conditions => { :main => true, :file_type => AudioAsset::EssenceFileType }
  end
  
  def find_main_metadata
    self.replicas.find :first, :conditions => { :main => true, :file_type => AudioAsset::MetadataFileType }
  end
end